package com.example.demo.multithread;

import java.util.concurrent.CompletableFuture;

public class MultithreadOrder4 {

    public static void main(String[] args) {
        Thread t1 = new Thread(new Worker(), "线程一");
        Thread t2 = new Thread(new Worker(), "线程二");
        Thread t3 = new Thread(new Worker(), "线程三");

        CompletableFuture.runAsync(() -> t1.start()).thenRun(() -> t2.start()).thenRun(() -> t3.start());

    }

    static class Worker implements Runnable {

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName());
        }
    }
}
